package service

import (
	"context"
	"fmt"

	"example/helloworld/api"
)

type helloWorldService struct {
}

func NewHelloWorldService() api.HelloWorldGinService {
	return &helloWorldService{}
}

func (s helloWorldService) Ping(ctx context.Context, req *api.PingRequest) (*api.PingResp, error) {
	return &api.PingResp{Ret: "pong"}, nil
}

func (s helloWorldService) Hello(ctx context.Context, req *api.HelloRequest) (*api.HelloResp, error) {
	return &api.HelloResp{Ret: fmt.Sprintf("hello, %s!", req.Name)}, nil
}

func (s helloWorldService) Hi(ctx context.Context, req *api.HiRequest) (*api.HiResp, error) {
	return &api.HiResp{Ret: fmt.Sprintf("hi, %s!", req.Name)}, nil
}
